<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="myuser.*" %>	

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jq/jquery-1.11.1.js"></script>
<script type="text/javascript">
$(function(){
	$("#userName").blur(function(){	//当用户名失去焦点时要做的事情
		if($.trim($(this).val())==""){	//1、用户名为空时，return
			return;	
		}
		$.post("user.do?op=checkExists",{userName:$(this).val(),pwd:""},function(data){	//2、用户名不为空时,判断用户名是否与已注册的重复
			$("[name='isExists']").val(data);
			if(data=="1"){
				$("#msg").html("该用户已注册111，请重新输入用户名");	
			}	
		});
	});	
	$("#btn").click(function(){
		if($.trim($("#userName").val())==""){
			$("#msg").html("用户名不能为空");
			return false;	
		}
		if($("[name='isExists']").val()=="1"){
			$("#msg").html("该用户已注册222，请重新输入用户名");
			return false;
		}
		if($.trim($("#pwd").val())==""){
			$("#msg").html("密码不能为空，请输入密码");	
			return false;
		}
		return true;
	});
});
</script>
</head>
<body>
	注册页面
	<br />
	<br />
	<form action="user.do?op=add" method="post">
		<table>
			<tr>
				<td width="60">用户名</td>
				<td width="171"><input type="text" name="userName"
					id="userName"></td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input type="password" name="pwd" id="pwd"></td>
			</tr>
			<input type="hidden" name="isExists" value="0">
			<tr>
				<td colspan="2"><input type="submit" value="提交" id="btn"></td>
			</tr>
		</table>
	</form>
	<div id="msg"></div>
	<br />
	<a href="main.jsp">返回主页面</a>
</body>
</html>